<template>
	<view class="wrap">
		<ul class="list">
			<li class="dlist" @click='show=true'>
				<span>注销账号</span>
				<view class="iconfont iconarrow-right" style="font-size: 40upx; color: #c3c3c3"></view>
			</li>
		</ul>
		<u-modal v-model="show" :content="content" :show-cancel-button="true" @confirm="exitandclose"></u-modal>
	</view>
</template>

<script>
	import {
		mapMutations
	} from "vuex";
	export default {
		data() {
			return {
				show: false,
				content: '是否要注销当前账号'
			};
		},
		methods: {
			...mapMutations(["logout"]),
			exitandclose() {
				uni.showLoading({
					title:'正在注销中，请等待'
				})
				this.config
					.post("/initUser/userCancel").then((res) => {
						console.log(res)
						if (res.data.code == 200) {
							setTimeout(() => {
								uni.showToast({
									title: '注销成功',
									icon: "success"
								})
								uni.hideLoading()
							}, 4000)
							setTimeout(()=>{
								this.logout();
								uni.navigateTo({
									url: "/pages/login/login2",
								});
							},6000)
						}
					});
			}

		}
	}
</script>

<style lang="scss" scoped>
	.wrap {
		padding: 30rpx;

		.list {
			list-style: none;
			padding: 0;

			.dlist {
				width: 100%;
				display: flex;
				justify-content: space-between;
				border-bottom: 1px solid #efefef;
				padding: 0 10rpx 20rpx 10rpx;
			}
		}
	}
</style>
